import App from './App'

// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
import uView from "uview-ui";
Vue.use(uView);

// 全局分享功能
import share from "mixins/share.js"
Vue.mixin(share)

// 消息提示
import msgUtils from './utils/msgUtils.js'
Vue.prototype.toast = msgUtils

// 复制
import h5Copy from "mixins/copy.js"

Vue.prototype.copy = function(code) {
	let content = code; // 复制内容，必须字符串，数字需要转换为字符串
	// #ifdef APP-PLUS || MP-WEIXIN
	uni.setClipboardData({
		data: content,
		success: function() {
			uni.showToast({
				title: '复制成功',
				icon: 'none'
			})
		},
	});
	// #endif
	// #ifdef H5
	const result = h5Copy(content)
	if (result === true) {
		uni.showToast({
			title: '复制成功',
			icon: 'none'
		})
	} else {
		uni.showToast({
			title: '复制失败',
			icon: 'none'
		})
	}
	// #endif
};

// 导入网络请求的包
import { $http } from '@escook/request-miniprogram'

uni.$http = $http

// 请求的根路径
$http.baseUrl = 'https://skdjmwj99.bxsmmcy.com/api/'
// 请求拦截器 
$http.beforeRequest = function(options) {
  options.header['token'] = uni.getStorageSync('token')
  // options.header['token'] = '853c2a63-29ed-4093-8e44-18f653a45bab'
}


// 响应拦截器
$http.afterRequest = function(options) {
  uni.hideLoading()
}

Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
  ...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif